//==================================================================
//  Copyright (C) 2006  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
//==
//==
//==
//==================================================================

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include "m5d_scene.h"
#include "m5d_pntsprt.h"

//==================================================================
namespace M5D
{

//==================================================================
PntSprt::PntSprt( Scene *scenep, const char *namep, int max_points, bool has_color ) :
	Model( Model::TYPE_PNTSPRT, scenep, namep ),
	_materialp(NULL),
	_n_active_points(0),
	_has_color(has_color),
	_max_size(128.0f),
	_is_read_lock(false),
	_is_write_lock(false),
	_is_instance(false)
{
	_displistp = new DispListBase( has_color ? PackVert::TYPE_POSCOL : PackVert::TYPE_POS,
								   max_points );
}

//==================================================================
PntSprt::PntSprt( Scene *scenep, const char *namep, PntSprt *copy_fromp ) :
	Model( Model::TYPE_PNTSPRT, scenep, namep ),
	_materialp(NULL),
	_max_size(128.0f),
	_n_active_points(0),
	_is_read_lock(false),
	_is_write_lock(false),
	_is_instance(false)
{
	PASSERT( 0 );
}

//==================================================================
PntSprt::~PntSprt()
{
	SAFE_DELETE( _displistp );
	_mod_scenep->HintFreedMaterials();
}

//==================================================================
void PntSprt::SetActiveVerts( u_int n )
{
	if ( _n_active_points != n )
	{
		_n_active_points = n;
		// $$$ _mod_scenep->OnModelModify( this );
	}
}

//==================================================================
void PntSprt::EndVerts()
{
	//if ( _is_write_lock )
	// $$$ 	_mod_scenep->OnModelModify( this );

	_is_write_lock = false;
	_is_read_lock = false;
}
};